package com.atguigu.day02;

import com.atguigu.utils.IntegerSource;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Example6 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        env
                .addSource(new IntegerSource())
                // 为每个数据指定一个key为1,这样所有数据都到同一个逻辑分区去了
                .keyBy(r -> 1)
                .max(0)
                .print("max:");

        env
                .addSource(new IntegerSource())
                // 为每个数据指定一个key为1,这样所有数据都到同一个逻辑分区去了
                .keyBy(r -> 1)
                .min(0)
                .print("min:");

        env.execute();
    }
}
